#!/usr/bin/perl


# Generate some amount of bodies randomly.

if ($#ARGV != 1){
    print "Usage: ./gen_random_bodies.pl <body_count> <file>\n";
    exit 1;
}

$num_bodies = $ARGV[0];

if ($num_bodies == 0){
    $num_bodies = 10000;
}

print "Body count: $num_bodies\n";
print "Writing data to file: $ARGV[1].phys\n";

# Gen the data:

open(GEN_OUT, ">$ARGV[1].phys");

while ($num_bodies--){
    @loc;
    @vel;
    for ( $i = 0; $i < 3; $i++){
	$loc[$i] = int((rand() * .5) * 10000000);
	$vel[$i] = int((rand() * .5) * 1000);
    }
    $width = 10;
    $mass = int((rand() * .5) * 100000000000000000);

    $body = "body: loc=[$loc[0]:$loc[1]:$loc[2]:0] " . 
	"vel=[$vel[0]:$vel[1]:$vel[2]:0] width=$width mass=$mass";

    print GEN_OUT "$body\n";
}
